#include <pthread.h>
#include <iostream>
using namespace std;
class Mutex
{
private:
    pthread_mutex_t *lock_;

public:
    Mutex(pthread_mutex_t *lock) : lock_(lock)
    {
    }
    ~Mutex()
    {
    }

public:
    void lock()
    {
        pthread_mutex_lock(lock_);
    }
    void unlock()
    {
        pthread_mutex_unlock(lock_);
    }
};
class lock_guard
{
private:
    Mutex mutex_;

public:
    lock_guard(pthread_mutex_t *lock) : mutex_(lock)
    {
        mutex_.lock();
    }
    ~lock_guard()
    {
        mutex_.unlock();
    }
};